@digital-commons-official/codeceptjs-storyboard 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -20
- package/package.json +1 -1
- package/src/index.d.ts +0 -2
- package/src/markdown-presentation.js +3 -58
- package/src/markdown.js +2 -4
package/README.md
CHANGED
|
@@ -161,14 +161,13 @@ The report starts with its recorded outcome and frame/step counts, followed by l
|
|
|
161
161
|
the result and replay information. A standalone render without an explicit outcome says
|
|
162
162
|
"Outcome not recorded"; it does not infer success from the absence of a visual failure.
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
chapters gets a journey banner. Screenshots sit in two equal-width columns by default. Each card keeps
|
|
164
|
+
Each chapter starts with a plain Markdown heading. Screenshots sit in two equal-width columns by default. Each card keeps
|
|
166
165
|
its title, image, note and copyable command together. Each pair has its own table so GitLab does not put
|
|
167
166
|
an entire chapter inside one scrolling region. Commands fold within their card; replay and source
|
|
168
167
|
details fold at the end. A failed comparison keeps Expected / Diff / Actual and unavailable-image
|
|
169
168
|
labels visible, regardless of the details setting.
|
|
170
169
|
|
|
171
|
-
### Markdown
|
|
170
|
+
### Markdown layout
|
|
172
171
|
|
|
173
172
|
Configure presentation directly on the plugin; no CSS file is needed:
|
|
174
173
|
|
|
@@ -177,11 +176,6 @@ storyboard: {
|
|
|
177
176
|
require: '@digital-commons-official/codeceptjs-storyboard',
|
|
178
177
|
enabled: true,
|
|
179
178
|
markdown: {
|
|
180
|
-
colors: {
|
|
181
|
-
banner: '#155e50',
|
|
182
|
-
bannerText: '#ffffff',
|
|
183
|
-
accent: '#559b84'
|
|
184
|
-
},
|
|
185
179
|
columns: 2,
|
|
186
180
|
tableOfContents: true,
|
|
187
181
|
technicalDetails: 'collapsed'
|
|
@@ -194,19 +188,10 @@ narrow screens. GitLab tables do not automatically stack like a responsive HTML
|
|
|
194
188
|
Set `technicalDetails: 'expanded'` to open commands and replay/source details, or
|
|
195
189
|
`tableOfContents: false` to omit navigation. Neither option removes evidence or notes.
|
|
196
190
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
ratio of at least 4.5:1. Invalid colours, unsupported options and invalid layout values raise a clear
|
|
200
|
-
error before the plugin registers listeners or the standalone renderer writes artifacts.
|
|
201
|
-
|
|
202
|
-
Generated banners live in an adjacent `_storyboard-assets/` directory and are named from their content.
|
|
203
|
-
**Commit these assets with the reviewed `.md` files and PNGs.** Keep that relative directory structure
|
|
204
|
-
when downloading runtime reports too. Repeated renders reuse the same asset names; unused older
|
|
205
|
-
assets are not automatically deleted. Banners are small decorations, not an additional full SVG report.
|
|
206
|
-
Long titles are abbreviated in the decoration but remain complete in the native Markdown heading.
|
|
191
|
+
Unsupported options and invalid layout values raise a clear error before the plugin registers
|
|
192
|
+
listeners or the standalone renderer writes artifacts.
|
|
207
193
|
|
|
208
|
-
|
|
209
|
-
background, fonts and native alert colours through the reader's preferences. Essential information
|
|
194
|
+
GitLab controls the page background, fonts and native alert colours through the reader's preferences. Essential information
|
|
210
195
|
remains text even when images cannot load. The renderer never recolours screenshots, loads external
|
|
211
196
|
assets, or applies the SVG-only `theme` option to Markdown. Explicit `format: 'svg'` keeps its existing
|
|
212
197
|
theme behaviour and ignores Markdown presentation settings.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-commons-official/codeceptjs-storyboard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Storyboard plugin for CodeceptJS: one Gherkin sentence = one card = one pixel baseline, with Markdown or SVG reports",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
package/src/index.d.ts
CHANGED
|
@@ -103,8 +103,6 @@ export interface StoryboardConfig {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface MarkdownPresentation {
|
|
106
|
-
/** Local banner colours, in 3/6-digit hex. Text is selected for contrast when omitted. */
|
|
107
|
-
colors?: { banner?: string, bannerText?: string, accent?: string }
|
|
108
106
|
/** Cards per row; defaults to 2. Use 1 for narrow readers. */
|
|
109
107
|
columns?: 1 | 2
|
|
110
108
|
/** Show chapter/result/replay navigation; defaults to true. */
|
|
@@ -1,71 +1,16 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const { createHash } = require('crypto')
|
|
4
|
-
|
|
5
|
-
const DEFAULT_COLORS = { banner: '#155e50', bannerText: '#ffffff', accent: '#559b84' }
|
|
6
|
-
|
|
7
1
|
function object (value, keys, label) {
|
|
8
2
|
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key => !keys.includes(key))) {
|
|
9
3
|
throw new Error(`storyboard markdown ${label} must be an object with supported keys: ${keys.join(', ')}`)
|
|
10
4
|
}
|
|
11
5
|
}
|
|
12
6
|
|
|
13
|
-
function luminance (color) {
|
|
14
|
-
const hex = color.slice(1)
|
|
15
|
-
const expanded = hex.length === 3 ? [...hex].map(character => character + character).join('') : hex
|
|
16
|
-
return [0, 2, 4].map(start => parseInt(expanded.slice(start, start + 2), 16) / 255)
|
|
17
|
-
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
|
|
18
|
-
.reduce((total, value, index) => total + value * [0.2126, 0.7152, 0.0722][index], 0)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function contrast (background, foreground) {
|
|
22
|
-
const values = [luminance(background), luminance(foreground)].sort((a, b) => b - a)
|
|
23
|
-
return (values[0] + 0.05) / (values[1] + 0.05)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
function normalizeMarkdown (value = {}) {
|
|
27
|
-
object(value, ['
|
|
28
|
-
const
|
|
29
|
-
object(supplied, Object.keys(DEFAULT_COLORS), 'colors')
|
|
30
|
-
const colors = { ...DEFAULT_COLORS, ...supplied }
|
|
31
|
-
for (const [key, color] of Object.entries(colors)) {
|
|
32
|
-
if (typeof color !== 'string' || !/^#(?:[\da-f]{3}|[\da-f]{6})$/i.test(color)) {
|
|
33
|
-
throw new Error(`storyboard markdown colors.${key} must be a 3- or 6-digit hex colour`)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (supplied.banner !== undefined && supplied.bannerText === undefined) {
|
|
37
|
-
colors.bannerText = contrast(colors.banner, '#ffffff') >= contrast(colors.banner, '#111111') ? '#ffffff' : '#111111'
|
|
38
|
-
if (contrast(colors.banner, colors.bannerText) < 4.5) colors.bannerText = '#000000'
|
|
39
|
-
}
|
|
40
|
-
if (contrast(colors.banner, colors.bannerText) < 4.5) throw new Error('storyboard markdown banner text contrast must be at least 4.5:1')
|
|
41
|
-
const options = { columns: 2, tableOfContents: true, technicalDetails: 'collapsed', ...value, colors }
|
|
8
|
+
object(value, ['columns', 'tableOfContents', 'technicalDetails'], 'options')
|
|
9
|
+
const options = { columns: 2, tableOfContents: true, technicalDetails: 'collapsed', ...value }
|
|
42
10
|
if (![1, 2].includes(options.columns)) throw new Error('storyboard markdown columns must be 1 or 2')
|
|
43
11
|
if (typeof options.tableOfContents !== 'boolean') throw new Error('storyboard markdown tableOfContents must be a boolean')
|
|
44
12
|
if (!['collapsed', 'expanded'].includes(options.technicalDetails)) throw new Error('storyboard markdown technicalDetails must be "collapsed" or "expanded"')
|
|
45
13
|
return options
|
|
46
14
|
}
|
|
47
15
|
|
|
48
|
-
|
|
49
|
-
return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Banners carry decoration only: the full chapter title also remains native
|
|
53
|
-
// Markdown, selectable and readable when images are unavailable or small.
|
|
54
|
-
function writeBanner (outFile, title, number, colors) {
|
|
55
|
-
const characters = Array.from(String(title).replace(/\s+/g, ' ').trim())
|
|
56
|
-
const label = characters.length > 38 ? characters.slice(0, 37).join('') + '…' : characters.join('')
|
|
57
|
-
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1120" height="104" viewBox="0 0 1120 104" role="img">
|
|
58
|
-
<title>${xml(title)}</title>
|
|
59
|
-
<rect width="1120" height="104" rx="8" fill="${colors.banner}"/>
|
|
60
|
-
<path d="M940 0h70l104 104h-70z M1060 0h30l30 30v74z" fill="${colors.accent}"/>
|
|
61
|
-
<text x="28" y="32" font-family="Arial, sans-serif" font-size="15" fill="${colors.bannerText}">${number ? 'Chapter ' + number : 'Journey'}</text>
|
|
62
|
-
<text x="28" y="73" font-family="Arial, sans-serif" font-size="26" font-weight="700" fill="${colors.bannerText}">${xml(label)}</text>
|
|
63
|
-
</svg>\n`
|
|
64
|
-
const digest = createHash('sha256').update(svg).digest('hex').slice(0, 20)
|
|
65
|
-
const file = path.join(path.dirname(outFile), '_storyboard-assets', `banner-${digest}.svg`)
|
|
66
|
-
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
67
|
-
fs.writeFileSync(file, svg)
|
|
68
|
-
return file
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = { normalizeMarkdown, writeBanner }
|
|
16
|
+
module.exports = { normalizeMarkdown }
|
package/src/markdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const { normalizeMarkdown
|
|
3
|
+
const { normalizeMarkdown } = require('./markdown-presentation')
|
|
4
4
|
|
|
5
5
|
// Annotations are plain text, not another source of Markdown or HTML.
|
|
6
6
|
function text (value) {
|
|
@@ -110,7 +110,6 @@ function renderMarkdown (board, outFile, options = {}) {
|
|
|
110
110
|
'[Replay and source](#storyboard-replay)'
|
|
111
111
|
].join(' · '))
|
|
112
112
|
}
|
|
113
|
-
if (!chapters.length) chunks.push(`)})`)
|
|
114
113
|
let pending = []
|
|
115
114
|
let chapterNumber = 0
|
|
116
115
|
const flush = () => {
|
|
@@ -121,8 +120,7 @@ function renderMarkdown (board, outFile, options = {}) {
|
|
|
121
120
|
if (card.chapter) {
|
|
122
121
|
flush()
|
|
123
122
|
chapterNumber++
|
|
124
|
-
|
|
125
|
-
chunks.push(`<a name="storyboard-chapter-${chapterNumber}"></a>`, `})`, `## ${caption(card.chapter).trim()}`)
|
|
123
|
+
chunks.push(`<a name="storyboard-chapter-${chapterNumber}"></a>`, `## ${caption(card.chapter).trim()}`)
|
|
126
124
|
}
|
|
127
125
|
if (failure && failure.frame && path.basename(card.file) === failure.frame.name) {
|
|
128
126
|
flush()
|